Python: Using `copyreg` to define reducers for types that already have reducers
Posted
by cool-RR
on Stack Overflow
See other posts from Stack Overflow
or by cool-RR
Published on 2010-05-28T21:48:27Z
Indexed on
2010/05/28
21:52 UTC
Read the original article
Hit count: 197
(Keep in mind I'm working in Python 3, so a solution needs to work in Python 3.)
I would like to use the copyreg
module to teach Python how to pickle functions. When I tried to do it, the _Pickler
object would still try to pickle functions using the save_global
function. (Which doesn't work for unbound methods, and that's the motivation for doing this.)
It seems like _Pickler
first tries to look in its own dispatch
for the type of the object that you want to pickle before looking in copyreg.dispatch_table
. I'm not sure if this is intentional.
Is there any way for me to tell Python to pickle functions with the reducer that I provide?
© Stack Overflow or respective owner